﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;

namespace ToDoList.Logic
{
    public class DataSource
    {

        public static List<Matter> matters = new List<Matter>();
        public static List<User> users = new List<User>();
        public static List<DetailedList> detailedLists = new List<DetailedList>();

        public DataSource()
        {
            var ExistingUser = new User()
            {
                UserID = 1,
                Password = "111111",
                NickName = "Oliver"

            };
            var ExistingDetailedList = new DetailedList()
            {
                ListID = 1,
                Time = DateTime.Now,
                NameOfList = "Good time"
            };
            List<Matter> ExistingMatter = new List<Matter>()
            {
                new Matter
                {
                    MatterID = 1,
                    Time = DateTime.Parse("2017/7/25 10:10:10"),
                    PastTime = "2017/7/26 10:10:10",
                    Content = "This noon we go to eat delicious fish",

                },

                new Matter
                {
                    MatterID = 2,
                    Time = DateTime.Now,
                    PastTime = "2017/7/28 10:10:10",
                    Content = "Tonight we go to bed earily"
                }

            };

            //将列表添加给用户
            ExistingUser.detailedLists = new List<DetailedList>();
            ExistingUser.detailedLists.Add(ExistingDetailedList);
            ExistingDetailedList.User = ExistingUser;

            //将事件添加给列表
            ExistingDetailedList.matters = new List<Matter>();
            ExistingDetailedList.matters.AddRange(ExistingMatter);
            //ExistingDetailedList.matters.SingleOrDefault(a => a.User == ExistingUser).User.UserID = ExistingUser.UserID;

            //将事件添加给用户
            ExistingUser.mattes = new List<Matter>();
            ExistingUser.mattes.AddRange(ExistingMatter);


            users.Add(ExistingUser);
            matters.AddRange(ExistingMatter);
            detailedLists.Add(ExistingDetailedList);

        }

        

    }
}
